<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据类型</title>
</head>
<body>
<script>
    var a=1;
    var b=2.23;
    console.log(a,b);
    console.log(typeof a,typeof b);//都是number类型
    var c='你';
    var d="你好666";
    console.log(c,d);
    console.log(typeof c,typeof d);//string
    var e=true
    var f= false
    console.log(typeof e,typeof f);//boolean
    var g;
    console.log(g,typeof g)//undefined


    let obj={};
    console.log(obj,typeof obj)
    let obj2={
        name:'张三',
        age:18
    };
    console.log(obj2,typeof obj2)
    console.log(obj2.name,obj2.age)
    obj2.like="吃火锅";
    console.log(obj2)
    obj2.play;
    console.log(obj2.play)
    let arr=['周一',3.3,6,obj]
    console.log(arr[99])//访问数组不存在的下标会得到undefined

    //boolean（）用于将参数转为布尔类型
    //0，undefined，null，“，NaN这五个特殊值转为布尔是false
    console.log(Boolean(0))
    console.log(Boolean(undefined))
    console.log(Boolean(null))
    console.log(Boolean(''))
    console.log(Boolean(NaN))
    console.log(Boolean(' '))
    console.log(Boolean(1))
    console.log(Boolean('早上好'))

    console.log(Number(true),typeof Number(true))//1, number
    console.log(Number(false),typeof Number(false))//1, number
    //number（）用于将参数转为数值类型，如果得不到数字结果，职为NaN
    console.log(Number('哈哈哈'),typeof Number('哈哈哈'))//NaN, number

</script>
</body>
</html>